package com.hualan.mapper;

import com.hualan.pojo.*;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface HotCourseMapper {

    @Select("select * from courses")
    List<HotCourse> findAll();

    @Select("select * from courses where id = #{id}")
    List<HotCourse> findById(Integer id);

    @Select("select * from courses where name like CONCAT('%',#{name},'%')")
    List<HotCourse> findLike(String name);

    @Select("select * from xuzhi where cid = #{cid}")
    List<XuZhi> xuzhis(Integer cid);

    @Select("SELECT * from teachers where id = (SELECT tid from courses where id = #{id})")
    Teachers teacher(Integer id);
    @Select("select * from pingjia where cid = #{cid}")
    @Results(id = "pingjia",value = {
            @Result(property = "user1",column = "uid",
            one = @One(select = "getname")
            )
    })
    List<PingJia> pingjia(Integer cid);


    @Select("select nickname from users where id = #{id}")
    User getname(Integer id);


}
